Back to Blog

Type error: Type does not satisfy the constraint 'PageProps'.

Category: it
nextjs
Views: 0

Type error: Type '{ params: { userId: string } }' does not satisfy the constraint 'PageProps'.

// Before

const User = async (
	{params: { userId }} : {params: { userId: string };
}) => {
	const [currentUserData] = await getCurrentUserData(userId);
};

// After

type Params = Promise<{ userId: string }>;

const User = async ({ params }: { params: Params }) => {
  const [currentUserData] = await getCurrentUserData(
    (await params).userId
  );
 };

https://nextjs.org/docs/app/guides/upgrading/version-15#async-request-apis-breaking-change

Comments (0)

Loading comments...

Log in to Comment